<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>nanosleep</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4><a name = "tag_000_007_859">&nbsp;</a>NAME</h4><blockquote>
nanosleep - high resolution sleep
(<b>REALTIME</b>)
</blockquote><h4><a name = "tag_000_007_860">&nbsp;</a>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="time.h.html">time.h</a>&gt;

int nanosleep(const struct timespec *<i>rqtp</i>, struct timespec *<i>rmtp</i>);
</code>
</pre>
</blockquote><h4><a name = "tag_000_007_861">&nbsp;</a>DESCRIPTION</h4><blockquote>
The
<i>nanosleep()</i>
function causes the current thread 
to be suspended from execution
until either the time interval specified by the
<i>rqtp</i>
argument has elapsed
or a signal is delivered to the calling thread
and its action is to invoke a signal-catching function
or to terminate the process.
The suspension time may be longer than requested
because the argument value is rounded up to an integer multiple of
the sleep resolution or
because of the
scheduling of other activity by the system.
But, except for the case of being interrupted by a signal, the
suspension time will not be less than the time specified by
<i>rqtp</i>,
as measured by the system clock, CLOCK_REALTIME.
<p>
The use of the
<i>nanosleep()</i>
function has no effect on the action or blockage of any signal.
</blockquote><h4><a name = "tag_000_007_862">&nbsp;</a>RETURN VALUE</h4><blockquote>
If the
<i>nanosleep()</i>
function returns because the requested time has elapsed,
its return value is zero.
<p>
If the
<i>nanosleep()</i>
function returns because it has been interrupted by a signal,
the function returns a value of -1 and sets
<i>errno</i>
to indicate the interruption.
If the
<i>rmtp</i>
argument is non-NULL, the
<b>timespec</b>
structure referenced by it
is updated to contain the amount of time remaining in the interval
(the requested time minus the time actually slept).
If the
<i>rmtp</i>
argument is NULL, the remaining time is not returned.
<p>
If
<i>nanosleep()</i>
fails, it returns a value of -1 and sets
<i>errno</i>
to indicate the error.
</blockquote><h4><a name = "tag_000_007_863">&nbsp;</a>ERRORS</h4><blockquote>
The 
<i>nanosleep()</i>
function will fail if:
<dl compact>

<dt>[EINTR]<dd>
The
<i>nanosleep()</i>
function was interrupted by a signal.

<dt>[EINVAL]<dd>
The
<i>rqtp</i>
argument specified a nanosecond
value less than zero or greater than or equal to 1000 million.

<dt>[ENOSYS]<dd>
The
<i>nanosleep()</i>
function is not supported by this implementation.

</dl>
</blockquote><h4><a name = "tag_000_007_864">&nbsp;</a>EXAMPLES</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_865">&nbsp;</a>APPLICATION USAGE</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_866">&nbsp;</a>FUTURE DIRECTIONS</h4><blockquote>
None.
</blockquote><h4><a name = "tag_000_007_867">&nbsp;</a>SEE ALSO</h4><blockquote>
<i><a href="sleep.html">sleep()</a></i>,
<i><a href="time.h.html">&lt;time.h&gt;</a></i>.
</blockquote><h4>DERIVATION</h4><blockquote>
Derived from the POSIX Realtime Extension (1003.1b-1993/1003.1i-1995)
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>

